<template>
  <div id="createGoodsActivity">
    <h1 class="con-right-title">
      新增活动
    </h1>
    <goodsActivityForm
      ref="goodsActivityInfo"
      class="form-content"
      @changeSaveStatus="changeSaveStatus"
    />
  </div>
</template>

<script>
import goodsActivityForm from '@component/goodsActivityManagement/components/goodsActivityForm'

export default {
  name: 'createGoodsActivity',
  msg: '新建商品活动',
  components: {
    goodsActivityForm
  },
  data() {
    return {}
  },
  mounted() {
    // window.addEventListener('beforeunload', () => this.beforeunloadHandler())
  },
  methods: {
    // 页面销毁缓存商品信息(已保存状态清空缓存，未保存缓存赠课商品信息)
    // beforeunloadHandler() {
    //   localStorage.setItem(
    //     'goodsActivityInfo',
    //     JSON.stringify({
    //       form: this.$refs.goodsActivityInfo.form,
    //       courseList: this.$refs.goodsActivityInfo.courseDialogData.courseList
    //     })
    //   )
    // },
    // 修改保存状态
    changeSaveStatus() {
      localStorage.removeItem('goodsActivityInfo')
    }
  }
}
</script>

<style lang="less" scoped>
#createGoodsActivity {
  .form-content {
    margin: 0 20px;
  }
}
</style>
